package com.lifu.yygh.common.utils;

import com.lifu.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description 获取当前用户信息的工具类
 * @Author lifu
 * @Date 2021/5/22 16:54
 */
public class AuthContextHolder {
    //获取当前用户id
    public static Long getUserId(HttpServletRequest httpServletRequest){
        String token = httpServletRequest.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }
    //获取当前用户名称
    public static String getUserName(HttpServletRequest httpServletRequest){
        String token = httpServletRequest.getHeader("token");
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
    //
}
